21. Labeled Data and Accuracy
Labeled Data and Accuracy
Why do we need labels?
You can tell if an image is night or day, but a computer cannot unless we tell it explicitly with a label!
This becomes especially important when we are testing the accuracy of a classification model.
A classifier takes in an image as input and should output a predicted_label
that tells us the predicted class of that image. Now, when we load in data, like you’ve seen, we load in what are called the true_labels
which are the correct labels for the image.
To check the accuracy of a classification model, we compare the predicted and true labels. If the true and predicted labels match, then we’ve classified the image correctly! Sometimes the labels do not match, which means we’ve misclassified an image.
Accuracy
After looking at many images, the accuracy of a classifier is defined as the number of correctly classified images (for which the predicted_label matches the true label) divided by the total number of images. So, say we tried to classify 100 images total, and we correctly classified 81 of them. We’d have 0.81 or 81% accuracy!
We can tell a computer to check the accuracy of a classifier only when we have these predicted and true labels to compare. We can also learn from any mistakes the classifier makes, as we’ll see later in this lesson.
Numerical labels
It’s good practice to use numerical labels instead of strings or categorical labels. They're easier to track and compare. So, for our day and night, binary class example, instead of "day" and "night" labels we’ll use the numerical labels: 0 for night and 1 for day.
Okay, now you’re familiar with the day and night image data AND you know what a label is and why we use them; you’re ready for the next steps. We’ll be building a classification pipeline from start to end!
Let’s first brainstorm what steps we’ll take to classify these images.